﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace ArrowScheduleCore
{
    /// <summary>
    /// Thrown when trying to save data where someone else has deleted the data after the user read the data they are working on.
    /// </summary>
    [Serializable]
    public class DeletedDataException : ApplicationException
    {
        /// <summary>
        /// Create an exception for when an update fails because it's been deleted since the update was read.
        /// </summary>
        public DeletedDataException()
        {
        }

        /// <summary>
        /// Create an exception for when an update fails because it's been deleted since the update was read.
        /// </summary>
        /// <param name="message">The exception message</param>
        public DeletedDataException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Create an exception for when an update fails because it's been deleted since the update was read.
        /// </summary>
        /// <param name="message">The exception message</param>
        /// <param name="innerException">An inner exception that caused this exception.</param>
        public DeletedDataException(string message, Exception innerException)
            : base(message, innerException)
        {
        }

        /// <summary>
        /// Initializes a new instance of the DeletedDataException class with serialized data.
        /// </summary>
        /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
        protected DeletedDataException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        /// <summary>
        /// Sets the SerializationInfo with information about the exception.
        /// </summary>
        /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
        [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
        }
    }
}
